import 'package:demo/app/widgets/line_horizontal.dart';
import 'package:demo/theme/app_colors.dart';
import 'package:demo/theme/app_text_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import 'dev_setting_controller.dart';

class DevSettingView extends GetView<DevSettingController> {
  const DevSettingView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color_bg,
      appBar: AppBar(
        title: const Text('开发设置'),
      ),
      body: Column(
        children: [
          SizedBox(height: 15.w),
          Container(
            padding: EdgeInsets.symmetric(horizontal: 15.w),
            height: 45.w,
            color: Colors.white,
            child: Row(
              mainAxisAlignment : MainAxisAlignment.spaceBetween,
              children: [
                Text('代理',style: text_131732_14),
                Obx(() => CupertinoSwitch(
                  value: controller.isOpenProxy.value,
                  onChanged: (isCheck)=> controller.isOpenProxy.value = isCheck,
                  activeColor:Color_main, // 开关打开时的颜色
                )),
              ],
            ),
          ),
          Obx(() => Visibility(
            visible: controller.isOpenProxy.value,
            child: Container(
              padding: EdgeInsets.only(left: 90.w,right: 15.w),
              color: Color_white,
              child: Column(
                children: [
                  const LineHorizontal(),
                  SizedBox(
                    height: 45.w,
                    child: Row(
                      mainAxisAlignment : MainAxisAlignment.spaceBetween,
                      children: [
                        Text('服务器',style: text_131732_14),
                        Expanded(
                          child: TextField(
                            controller: controller.hostController,
                            textAlign: TextAlign.right,
                            style: text_131732_14,
                            decoration: InputDecoration(
                              prefixText: "  ",
                              isDense: true,
                              contentPadding: EdgeInsets.symmetric(vertical: 12.w),
                              counterText: "", // 去掉底部计数
                              enabledBorder:  const UnderlineInputBorder(borderSide: BorderSide.none), //无焦点时状态
                              focusedBorder:  const UnderlineInputBorder(borderSide: BorderSide.none), //有焦点时状态
                              hintText: '请输入代理地址',
                              hintStyle: text_grey_14,
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  const LineHorizontal(),
                  SizedBox(
                    height: 45.w,
                    child: Row(
                      mainAxisAlignment : MainAxisAlignment.spaceBetween,
                      children: [
                        Text('端口',style: text_131732_14),
                        Expanded(
                          child: TextField(
                            controller: controller.portController,
                            textAlign: TextAlign.right,
                            style: text_131732_14,
                            decoration: InputDecoration(
                              prefixText: "  ",
                              isDense: true,
                              contentPadding: EdgeInsets.symmetric(vertical: 12.w),
                              counterText: "", // 去掉底部计数
                              enabledBorder:  const UnderlineInputBorder(borderSide: BorderSide.none), //无焦点时状态
                              focusedBorder:  const UnderlineInputBorder(borderSide: BorderSide.none), //有焦点时状态
                              hintText: '请输入代理端口',
                              hintStyle: text_grey_14,
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          )),
          Container(
            decoration: BoxDecoration(
                color: Color_white,
                border: Border(top: BorderSide(color: Color_line, width: 0.2.w))
            ),
            padding: EdgeInsets.symmetric(horizontal: 15.w),
            height: 45.w,
            child: Row(
              mainAxisAlignment : MainAxisAlignment.spaceBetween,
              children: [
                Text('是否正式线',style: text_131732_14),
                Obx(() => CupertinoSwitch(
                  value: !controller.isTestUrl.value,
                  onChanged: (isCheck)=> controller.isTestUrl.value = !controller.isTestUrl.value,
                  activeColor:Color_main, // 开关打开时的颜色
                )),
              ],
            ),
          ),
          SizedBox(height: 15.w),
          Container(
              padding: EdgeInsets.only(left: 15.w),
              width: Get.width,
              child: Text('修改完记得点击保存，点击返回将不生效',style: text_main_12b.copyWith(color: Color_red))),
          SizedBox(height: 15.w),

          SizedBox(height: 15.w),
          InkWell(
            onTap: () => controller.toFace(),
            child: Container(
              decoration: BoxDecoration(
                  color: Color_white,
                  border: Border(bottom: BorderSide(color: Color_line, width: 0.2.w))
              ),
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              height: 45.w,
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                children: [
                  Text('人脸识别',style: text_131732_14),
                  Text('临时item',style: text_grey_14),
                ],
              ),
            ),
          ),
          InkWell(
            onTap: () => controller.toBank(),
            child: Container(
              decoration: BoxDecoration(
                  color: Color_white,
                  border: Border(bottom: BorderSide(color: Color_line, width: 0.2.w))
              ),
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              height: 45.w,
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                children: [
                  Text('银行卡识别',style: text_131732_14),
                  Text('临时item',style: text_grey_14),
                ],
              ),
            ),
          ),
          InkWell(
            onTap: () => controller.toScanIdFront(true),
            child: Container(
              decoration: BoxDecoration(
                  color: Color_white,
                  border: Border(bottom: BorderSide(color: Color_line, width: 0.2.w))
              ),
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              height: 45.w,
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                children: [
                  Text('身份证头像面',style: text_131732_14),
                  Text('临时item',style: text_grey_14),
                ],
              ),
            ),
          ),
          InkWell(
            onTap: () => controller.toScanIdFront(false),
            child: Container(
              decoration: BoxDecoration(
                  color: Color_white,
                  border: Border(bottom: BorderSide(color: Color_line, width: 0.2.w))
              ),
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              height: 45.w,
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                children: [
                  Text('身份证国徽面',style: text_131732_14),
                  Text('临时item',style: text_grey_14),
                ],
              ),
            ),
          ),
          InkWell(
            onTap: () => controller.toAd(),
            child: Container(
              decoration: BoxDecoration(
                  color: Color_white,
                  border: Border(bottom: BorderSide(color: Color_line, width: 0.2.w))
              ),
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              height: 45.w,
              child: Row(
                mainAxisAlignment : MainAxisAlignment.spaceBetween,
                children: [
                  Text('加载广告',style: text_131732_14),
                  Text('临时item',style: text_grey_14),
                ],
              ),
            ),
          ),

          Expanded(child: Container()),
          RawMaterialButton(
            fillColor: Color_main,
            elevation:0,
            highlightElevation:0,
            shape : RoundedRectangleBorder(borderRadius : BorderRadius.all(Radius.circular(22.w))),
            constraints: BoxConstraints.tightFor(width: Get.width - 60.w, height:44.w),
            child: Text('保存',style: text_white_16b),
            onPressed: ()=> controller.save(),
          ),
          SizedBox(height: 30.w)
        ],
      ),
    );
  }
}
